def main():
    class DrawList:
        def __init__(self, lst):
            self.lst = lst
            
        def Draw(self, lst, x, y):
            self.lst = lst
            self.x = x
            self.y = y
            self.w = len(lst[0])
            self.h = len(lst)
            ####################
            if self.x >= 0 and self.x <= self.w:
                if self.y >= 0 and self.y <= self.h:
                    if self.lst[self.y - 1][self.x - 1] == ".":
                        self.lst[self.y - 1][self.x - 1] = "#"
                    elif self.lst[self.y - 1][self.x - 1] == "#":
                        self.lst[self.y - 1][self.x - 1] = "."
                    return self.lst
            return None
        
        def out(self):
            print("[")
            for i in lst:
                print(f"    {i}")
            print("]")

    def ClearList():
        global lst
        lst = [
            ['.', '.', '.', '.', '.'],
            ['.', '.', '.', '.', '.'],
            ['.', '.', '.', '.', '.'],
            ['.', '.', '.', '.', '.'],
            ['.', '.', '.', '.', '.']
        ]

    lst = [
        ['.', '.', '.', '.', '.'],
        ['.', '.', '.', '.', '.'],
        ['.', '.', '.', '.', '.'],
        ['.', '.', '.', '.', '.'],
        ['.', '.', '.', '.', '.']
    ]
    ClearList()

    draw1 = DrawList(lst)
    print("Input 'x' and 'y' to draw.")
    print("Input 'q' to quit.")
    print("Input 'x' to watch the picture.")
    print("Input 'z' to clear the picture.\n")

    while True:
        x = input("Input x! ")
        if x == "x":
            draw1.out()
            continue
        elif x == "q":
            return
        elif x == "z":
            ClearList()
            continue
        try:
            x = int(x)
        except:
            continue
        print("TangTang nb!")
        
        y = input("Input y! ")
        if y == "x":
            draw1.out()
            continue
        elif y == "q":
            return
        elif y == "z":
            ClearList()
            continue
        try:
            x = int(x)
        except:
            continue
        print("TangTang nb!")
        #####################
        try:
            x = int(x)
            y = int(y)
        except:
            print("input again, please.")
            continue
        else:
            Lst = lst[:]
            lst = draw1.Draw(lst, x, y)
            if lst == None:
                print("again")
                lst = Lst[:]
                draw1 = DrawList(lst)
                draw1.out()
                

    print("over!")


main()